<template>
	<div>
		<div class="pub-title">后台管理</div>
		<ul class="pub-tab">
			<li class="option-list">
				<a href="article.html" class="option on">会员资料</a> 
				<!-- <a href="article_classify.html" class="option">分类</a> -->
			</li>
			<li class="tab-block-list">
				<div class="pub-form-line">
					<div class="pub-form-line-left">手机号</div>
					<div class="pub-form-line-right">
						<input type="text" class="pub-input" v-model="member.mobile" readonly="readonly" />
						<input type="hidden" v-model="member._id" />
					</div>
				</div>
				
				<div class="pub-form-line">
					<div class="pub-form-line-left">注册时间</div>
					<div class="pub-form-line-right">
						<input type="text" class="pub-input" readonly="readonly" :value="date" placeholder="默认互联网" />
					</div>
				</div> 
 
			

				<div class="pub-form-line">
					<div class="pub-form-line-left sign">会员等级</div>
					<div class="pub-form-line-right">
						<select v-model="member.grade" style="width:160px;"> 						
							<option value="1" :selected="member.grade==1">普通会员</option>
							<option value="2" :selected="member.grade==2">vip会员</option>
						</select>
					</div>
				</div>
				
				
				<div class="pub-form-line">
					<div class="pub-form-line-left sign">是否冻结</div>
					<div class="pub-form-line-right">
						<select v-model="member.disabled" style="width:160px;">
							<option value="0" :selected="member.disabled==0">正常</option>
							<option value="1" :selected="member.disabled==1">冻结</option>
						</select>
					</div>
				</div>
				
				<div class="pub-form-line">
					<div class="pub-form-line-left sign">过期时间</div>
					<div class="pub-form-line-right">
						<input type="text" readonly class="pub-input pub-date" id="expired" @change="expiredChange" style="cursor: pointer;"  placeholder="过期时间" />
					</div>
				</div>
				
				<div class="pub-form-line">
					<div class="pub-form-line-left"></div>
					<div class="pub-form-line-right">
						<button class="pub-btn pub-btn-bgred pub-btn-big" @click="submit">提交</button>
					</div>
				</div>
				
			</li>
		</ul>
	</div> 
</template> 

<script>
	module.exports = {
		data: function() {
			return {
				expired:"",
				member: {},
			} 
		},
		computed:{
			date:function(){
				if(!this.member.create_time){
					return "";
				}else{
					return vm.formatDate(this.member.create_time);
				}
			}			
		},
		methods: {
			expiredChange(){
				this.member.expired=new Date(document.querySelector('#expired').value).getTime();
			},
			submit() {			
				ajax({
					url: 'member/update',
					data: this.member,
					type: 'post',
					success: function(res) {
						if (res.state == 1) {
							location.href = "member.html";
						} else {
							UI.alert(res.msg);
						}
					} 
				}) 
			}			
		},
		mounted() {
			_this = this;
			jeDate({dateCell:'#expired',skinCell:"jedatered",isTime:true,format:'YYYY-MM-DD hh:mm:ss',choosefun:function(){
				_this.expiredChange();
			}});
			if (query.id) {
				ajax({
					url: "member/get", 
					data: {
						id: query.id
					}, 
					success: function(res) {
						if (res.state == 1) {
							if(res.data.expired){
								document.querySelector('#expired').value=vm.formatDate(res.data.expired);
							}
							if(!res.data.grade)res.data.grade=1;
							_this.member=res.data;
						} else {
							UI.alert(res.msg);
						}
					}
				})
			}
		}
	}
</script>
